<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <title>修改用户</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi"/>

    <link rel="stylesheet" href="../../static/css/font.css" th:href="@{/css/font.css}">
    <link rel="stylesheet" href="../../static/css/xadmin.css" th:href="@{/css/xadmin.css}">
    <script src="../../static/js/jquery-3.2.1.min.js" type="text/javascript" th:src="@{/js/jquery-3.2.1.min.js}"></script>
    <script src="../../static/js/vue.js" type="text/javascript" th:src="@{/js/vue.js}"></script>
    <script src="../../static/lib/layui/layui.js" charset="utf-8" th:src="@{/lib/layui/layui.js}"></script>
    <script type="text/javascript" src="../../static/js/xadmin.js" th:src="@{/js/xadmin.js}"></script>


    <link rel="stylesheet" th:href="@{/lib/layui/css/layui.css}">
    <link rel="stylesheet" th:href="@{/bootstrap/css/bootstrap.min.css}">
    <script th:src="@{/bootstrap/js/bootstrap.min.js}" type="text/javascript"></script>

    <style>
        .layui-form-item{
            padding-left: 110px;
        }
        .layui-btn{
            margin-left: 47px;
        }
    </style>
</head>

<body>

<div class="x-body">
    <form class="layui-form">
        <!-- 姓名框起始位置-->
        <div class="layui-form-item">
            <label for="name" class="layui-form-label">
                姓名
            </label>
            <div class="layui-input-inline">
                <input type="hidden" id="userId" name="userId" th:value="${user.userId}">
                <input type="text" id="name" name="name" required=""
                       autocomplete="off" th:value="${user.name}" class="layui-input">
            </div>
        </div>
        <!-- 姓名框结束位置-->

        <!-- 性别框起始位置-->
        <div class="layui-form-item">
            <label for="sex" class="layui-form-label">
                性别
            </label>
            <div class="layui-input-inline">
                <select id="sex">
                    <option value="男" th:selected="${user.sex == '男'}">男</option>
                    <option value="女" th:selected="${user.sex == '女'}">女</option>
                    <option value="其他" th:selected="${user.sex == '其他'}">其他</option>
                </select>
            </div>
        </div>
        <!-- 性别框结束位置-->

        <!-- 年龄框起始位置-->
        <div class="layui-form-item">
            <label for="phone" class="layui-form-label">
                电话
            </label>
            <div class="layui-input-inline">
                <input type="text" id="phone" name="phone" required="" th:value="${user.phone}"
                       autocomplete="off" class="layui-input">
            </div>
        </div>
        <!-- 年龄框结束位置-->

        <div class="layui-form-item">
            <label for="username" class="layui-form-label">
                用户名
            </label>
            <div class="layui-input-inline">
                <input type="text" id="username" name="username" required="" disabled th:value="${user.username}"
                       autocomplete="off" class="layui-input">
            </div>
        </div>

        <!-- 修改按钮起始位置-->
        <div class="layui-form-item">
            <label class="layui-form-label">
            </label>
            <button class="layui-btn" lay-filter="*" lay-submit >
                修改
            </button>
        </div>
        <!-- 修改按钮结束位置-->
    </form>
</div>
<script>
        layui.use(['form','layer'], function() {
            $ = layui.jquery;
            var form = layui.form
                , layer = layui.layer;

            //自定义验证规则
            form.on('submit(*)', function (data) {
                console.log(data);
                $.ajax({
                    url: "/user/examineeUpdate",
                    type: "post",
                    data: data.field,
                    dataType: "json",
                    success: function (rs) {
                        console.log(rs);
                        if (rs.code == 200){
                            layer.alert(rs.msg, {icon: 6}, function () {
                                // if (rs.success) {
                                    var index = parent.layer.getFrameIndex(window.name);
                                    //关闭当前frame
                                    parent.layer.close(index);
                                    //刷新
                                    parent.window.loadData();
                                // }
                            });
                        }else {
                            layer.open({
                                title: '修改考生信息'
                                ,content: '修改失败!2333333'
                            });
                        }
                    },error:function () {
                        layer.open({
                            title: '系统消息'
                            ,content: '服务器错误!'
                        });
                    }
                })

                return false;
            });
        });
</script>

</body>

</html>